home *** CD-ROM | disk | FTP | other *** search
- /* *****************************************************************************
- *
- * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- *
- ***************************************************************************** */
- #include <gl.h>
- #include <device.h>
- #include <math.h>
- #include "fast.h"
- #include "event.h"
-
- extern int mainmenu, quitmenu;
-
- void display();
-
- int do_exit;
- int ask_quit;
-
- int max_size, this_size;
- int this_proc;
-
- int *image, *show_image;
- int *my_index;
-
- double this_time, this_flop;
- extern int x_size, y_size, n_total;
- char message[64];
- void InitFast(char *filename);
- double second();
-
- int do_compar(int *, int *);
-
- fast (char *filename)
- {
- InitFast(filename);
- Init(filename);
-
- do_exit = FALSE;
-
- display();
-
- while(! do_exit) {
- event();
- }
- }
-
- ShowFast()
- {
- char str[32];
-
- cpack (oBLACK);
- clear ();
-
- cpack (oGREEN);
- ortho2(0,ZOOM_FACTOR*x_size+2*BORDER,0, ZOOM_FACTOR*y_size+2*BORDER);
- cmov2i( 250, ZOOM_FACTOR*y_size+BORDER+20);
- sprintf( str, "SIZE = %d x %d", x_size, y_size);
- charstr(str);
-
- cmov2i( 200, 20);
- charstr(message);
-
- DrawFast();
- }
-
- void do_quit()
- {
- gexit();
- exit(0);
- }
-
-
- void do_rightmouse()
- {
- ask_quit = 0;
-
- dopup(mainmenu);
-
- if(ask_quit)
- dopup(quitmenu);
-
- }
-
- void display()
- {
- reshapeviewport();
- ShowFast();
- swapbuffers();
- }
-
- void do_reset(){
-
- int i;
- for(i= 0; i < n_total; i++)
- my_index[i] = i;
- do_mix();
- strcpy(message,"");
- display();
- }
-
- do_shuffle(){
- int i, j, k;
- for( i = 0; i < n_total; i++){
- j = random() % n_total;
- k = my_index[i];
- my_index[i] = my_index[j];
- my_index[j] = k;
- }
- do_mix();
- strcpy(message,"");
- display();
- }
-
- do_mix(){
- int i;
- for(i = 0; i< n_total; i++)
- show_image[i] = image[my_index[i]];
- }
-
- void this_run(){
-
- this_time = second();
- qsort(my_index, n_total, sizeof(int), do_compar);
- this_time = second() - this_time;
- do_mix();
- sprintf(message, "Qsort done in %.2f Seconds",this_time);
- display();
- }
-
- void that_run(){
-
- this_time = second();
- psort(my_index, n_total, sizeof(int), do_compar);
- this_time = second() - this_time;
- do_mix();
- sprintf(message, "Psort done in %.2f Seconds",this_time);
- display();
- }
-
- void update_(int *k){
- this_size = *k;
-
- display();
- }
-
- void this_quit(){
-
- ask_quit = 1;
- }
- void InitFast(char *filename){
-
- this_proc = mpc_numthreads();
- readrgb(filename);
- show_image = (int *)malloc(n_total * sizeof(int));
- my_index = (int *)malloc(n_total * sizeof(int));
- }
-
- int do_compar( int *a, int *b)
- {
- if( (*a) < (*b))
- return (-1);
- if( (*a) > (*b))
- return (1);
- return (0);
- }
-
-